#!/bin/sh
# $Id: libproxy_proxy_and_lib.test 386 2009-06-07 20:15:13Z dominique.leuenberger $

lib=$(/sbin/ldconfig -p 2>/dev/null | awk '/libproxy.so /{print $NF}')
proxy=$(which proxy 2>/dev/null)
build=src/bin/proxy

# Make sure libproxy is built and a valid dynamic library
if ! nm $lib 2>/dev/null | grep -qs _DYNAMIC; then
    nm src/lib/.libs/libproxy.so 2>/dev/null | grep -qs _DYNAMIC
    if [ $? -eq 0 ]; then
        # Try to be intelligent and use the library in the build dir
        # before we start running the rest of the tests
        export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:src/lib/.libs"
        lib=src/lib/.libs/libproxy.so
    fi
fi  

# Prefer the freshly built version over the installed version
if [ ! -x "$proxy" -a -x $build ]; then
    proxy=$build
fi  

if [ "$proxy" -a "$lib" ]; then
    echo pass=True
else
    echo pass=False
    echo 'reason="unable to access the library, try: make"'
fi  
